﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MpSoft.Library.DAO.Contents;
using MpSoft.Library.DTO;
using MpSoft.Basic.Configuration;

namespace MpSoft.Library.BUSS.Contents
{
    #region  DownloadLanguage
    
    public class DownloadLanguageBUSS
    {
        private const string DOWNLOADLANGUAGE_ALL_KEY = "Mp.downloadlanguage.all-{0}";
        private const string DOWNLOADLANGUAGE_BY_ID_KEY = "Mp.downloadlanguage.id-{0}";
        
        private static void DownloadLanguageRemoveCache()
        {
             MpCache.RemoveByPattern(DOWNLOADLANGUAGE_ALL_KEY);
             MpCache.RemoveByPattern(DOWNLOADLANGUAGE_BY_ID_KEY);
        }
        
        public static int DownloadLanguage_Add(DownloadLanguage obj)
        {
            var result = DownloadLanguageDAO.DownloadLanguage_Add(obj);
            return result;
        }
        public static int DownloadLanguage_Update(DownloadLanguage obj)
        {
            var result = DownloadLanguageDAO.DownloadLanguage_Update(obj);
            return result;
        }

        public static int DownloadLanguage_Delete(int DLID)
        {
            var result = DownloadLanguageDAO.DownloadLanguage_Delete(DLID);
            return result;
        }

        public static DownloadLanguage DownloadLanguage_ByID(int DLID)
        {
            var list = DownloadLanguage_Select(DLID, -1, null);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static DownloadLanguage DownloadLanguage_ByID(int DownloadID, string LanguageCode)
        {
            var list = DownloadLanguage_Select(-1, DownloadID, LanguageCode);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static List<DownloadLanguage> DownloadLanguage_Select(int DLID, int DownloadID, string LanguageCode)
        {
            return DownloadLanguageDAO.DownloadLanguage_Select(DLID, DownloadID, LanguageCode);
        }

    }
    
    #endregion
}

